package com.mywang.weitravel.net;

import com.mywang.weitravel.model.ChangeAvatarResponse;
import com.mywang.weitravel.model.CollectionResponse;
import com.mywang.weitravel.model.FindDetailResponse;
import com.mywang.weitravel.model.FindListBean;
import com.mywang.weitravel.model.FootprintListBean;
import com.mywang.weitravel.model.HomeListBean;
import com.mywang.weitravel.model.ReadDetailBean;
import com.mywang.weitravel.model.RedLocateListBean;
import com.mywang.weitravel.model.StudyBean;
import com.mywang.weitravel.model.StudyDetailBean;
import com.mywang.weitravel.model.UploadAvatarResponse;
import com.mywang.weitravel.model.UserBean;
import com.mywang.weitravel.model.base.BaseResponse;
import com.mywang.weitravel.model.base.UploadResponse;
import com.mywang.weitravel.modules.ReadTypeBean;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Query;
import retrofit2.http.QueryMap;

/**
 * 请求数据接口
 *
 * @author Veer
 * @email 276412667@qq.com
 * @date 18/7/2
 */

public interface ApiService {

    //注册
    @FormUrlEncoded
    @POST(value = "register")
    Observable<BaseResponse> doRegister(@FieldMap Map<String, String> params);

    //登录
    @FormUrlEncoded
    @POST(value = "login")
    Observable<BaseResponse<UserBean>> doLogin(@FieldMap Map<String, String> params);

    //退出登录
    @GET(value = "user/logout")
    Observable<BaseResponse> doLogOut(@FieldMap Map<String, String> params);

    //首页
    @GET(value = "index")
    Observable<BaseResponse<List<HomeListBean>>> getHomeList();

    //发现
    @GET(value = "find")
    Observable<BaseResponse<FindListBean>> getFindList(@QueryMap Map<String, String> params);

    //足迹
    @GET(value = "mark")
    Observable<BaseResponse<FootprintListBean>> getFootprintList(@QueryMap Map<String, String> params);

    //红色寻访
    @GET(value = "index/red_look")
    Observable<BaseResponse<List<RedLocateListBean>>> getRedLocateList(@QueryMap Map<String, String> params);

    //研学
    @GET(value = "index/study_travel")
    Observable<BaseResponse<List<StudyBean>>> getStudyList();

    //研学
    @GET(value = "index/study_travel_detail")
    Observable<BaseResponse<StudyDetailBean>> getStudyDetail(@QueryMap Map<String, String> params);

    //阅读中国
    @GET(value = "index/read_china_cate")
    Observable<BaseResponse<List<ReadTypeBean>>> getReadType();

    //阅读中国
    @GET(value = "index/read_china")
    Observable<BaseResponse<List<ReadDetailBean>>> getReadList(@QueryMap Map<String, String> params);

    Observable<BaseResponse<List<StudyBean>>> getReadList();

    @POST("upload/many_image")
    @Multipart
    Observable<BaseResponse<UploadResponse>> uploadFile(@Part List<MultipartBody.Part> partList);

    @FormUrlEncoded
    @POST("find/add")
    Observable<BaseResponse<Object>> publishDiscovery(@FieldMap Map<String, String> params);

    @FormUrlEncoded
    @POST("user/pwd")
    Observable<BaseResponse<Object>> changePwd(@Field("password") String password, @Field("cpassword") String cpassword);

    @GET("user/sign")
    Observable<BaseResponse<Object>> sign();

    @POST("user/detail")
    Observable<BaseResponse<UserBean>> getUserInfo();

    @GET("user/mine_collect")
    Observable<BaseResponse<CollectionResponse>> getCollectionList(@Query("page") int page);

    @GET("find/support")
    Observable<BaseResponse<Object>> likeFind(@Query("find_id") String findId);

    @GET("find/detail ")
    Observable<BaseResponse<FindDetailResponse>> getFindDetail(@Query("id") String findId);

    @FormUrlEncoded
    @POST("user/nikename")
    Observable<BaseResponse<Object>> changeUserName(@Field("nickname") String username);

    @FormUrlEncoded
    @POST("user/avatar")
    Observable<BaseResponse<ChangeAvatarResponse>> changeAvatar(@Field("avatar") String avatar);

    @POST("upload/image")
    @Multipart
    Observable<BaseResponse<UploadAvatarResponse>> uploadAvatar(@Part MultipartBody.Part part);

    @GET("find/collect")
    Observable<BaseResponse<Object>> collect(@Query("find_id") String findId);

    //足迹点赞
    @GET("mark/support")
    Observable<BaseResponse<Object>> likeMark(@Query("find_id") String findId);

    //红色寻访点赞
    @GET("index/red_look_support")
    Observable<BaseResponse<Object>> likeRed(@Query("red_id") String findId);
}
